package net.suncapper.wcss.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.suncapper.wcss.model.domain.BatchSetting;
import net.suncapper.wcss.mapper.BatchSettingMapper;
import net.suncapper.wcss.model.dto.PageDTO;
import net.suncapper.wcss.service.IBatchSettingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 批次设定 服务实现类
 * </p>
 *
 * @author ztr
 * @since 2025-11-06
 */
@Service
public class BatchSettingServiceImpl extends ServiceImpl<BatchSettingMapper, BatchSetting> implements IBatchSettingService {
  @Autowired
    private BatchSettingMapper batchSettingMapper;
    @Override
    public Page<BatchSetting> pageList(BatchSetting batchSetting, PageDTO pageDTO) {
       Page<BatchSetting> page = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        List<BatchSetting> batchSettings =batchSettingMapper.selectLists(page, batchSetting);
        Page<BatchSetting> resultPage = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        resultPage.setRecords(batchSettings);
        resultPage.setTotal(page.getTotal()); // 复用总条数
        return resultPage;
    }

    @Override
    public Integer insert(BatchSetting bs) {
        int insert = batchSettingMapper.insert(bs);
        return insert;
    }

    @Override
    public Page<BatchSetting> pageLists(BatchSetting batchSetting, PageDTO pageDTO) {
        Page<BatchSetting> page = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        List<BatchSetting> batchSettings =batchSettingMapper.selectList1(page, batchSetting);
        Page<BatchSetting> resultPage = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        resultPage.setRecords(batchSettings);
        resultPage.setTotal(page.getTotal()); // 复用总条数
        return resultPage;
    }



}
